FrameLib  0.1
Arbitrarily timed and sized frame-based DSP
FrameLib_Info.h
Go to the documentation of this file.
1 
2 #ifndef FRAMELIB_INFO_H
3 #define FRAMELIB_INFO_H
4 
5 #include <string>
6 #include <sstream>
7 #include <iostream>
8 
9 // FrameLib_Info is a class to simplify creating info strings (provides storage, index replacement and switching between brief and verbose versions)
10 // For many cases use of const strings with this class will be sufficient
11 
13 {
14 
15 public:
16 
17  const char *getInfo(const char *verboseStr, const char *briefStr, bool verbose)
18  {
19  const char *outStr = verbose ? verboseStr : briefStr;
20 
21  return outStr;
22  }
23 
24  std::string getInfo(const char *verboseStr, const char *briefStr, unsigned long idx, bool verbose)
25  {
26  std::string info;
27  std::ostringstream idxStr;
28 
29  idxStr << (idx + 1);
30 
31  info = getInfo(verboseStr, briefStr, verbose);
32 
33  for (size_t pos = info.find("#", 0); pos != std::string::npos; pos = info.find("#", pos + 1))
34  info.replace(pos, 1, idxStr.str());
35 
36  return info;
37  }
38 
39  std::string getInfo(const char *verboseStr, const char *briefStr, const char *replaceStr, bool verbose)
40  {
41  std::string info;
42  getInfo(verboseStr, briefStr, verbose);
43 
44  for (size_t pos = info.find("#", 0); pos != std::string::npos; pos = info.find("#", pos + 1))
45  info.replace(pos, 1, replaceStr);
46 
47  return info;
48  }
49 };
50 
51 #endif
std::string getInfo(const char *verboseStr, const char *briefStr, unsigned long idx, bool verbose)
Definition: FrameLib_Info.h:24
std::string getInfo(const char *verboseStr, const char *briefStr, const char *replaceStr, bool verbose)
Definition: FrameLib_Info.h:39
const char * getInfo(const char *verboseStr, const char *briefStr, bool verbose)
Definition: FrameLib_Info.h:17
Definition: FrameLib_Info.h:12